<template>
  <div class="edit-home">
    <div class="header">
      <h1>工作流编辑器</h1>
      <div class="actions">
        <button @click="showWorkflowEditor = true" class="action-button">打开工作流编辑器</button>
      </div>
    </div>
    
    <div class="content">
      <div v-if="!showWorkflowEditor" class="welcome">
        <div class="welcome-card">
          <h2>欢迎使用JSON工作流编辑器</h2>
          <p>这是一个可视化的工作流编辑工具，您可以通过拖拽节点和连接来创建工作流程。</p>
          <p>点击上方的"打开工作流编辑器"按钮开始使用。</p>
          
          <div class="features">
            <div class="feature">
              <div class="feature-icon">📝</div>
              <div class="feature-title">可视化编辑</div>
              <div class="feature-desc">通过拖拽方式创建和编辑工作流</div>
            </div>
            
            <div class="feature">
              <div class="feature-icon">🔄</div>
              <div class="feature-title">导入导出</div>
              <div class="feature-desc">支持JSON格式的工作流导入和导出</div>
            </div>
            
            <div class="feature">
              <div class="feature-icon">🧩</div>
              <div class="feature-title">多种节点</div>
              <div class="feature-desc">提供开始、处理、条件、结束等多种节点类型</div>
            </div>
          </div>
        </div>
      </div>
      
      <div v-else class="editor-wrapper">
        <button @click="showWorkflowEditor = false" class="back-button">
          返回
        </button>
        <WorkflowEditor />
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue';
import WorkflowEditor from './WorkflowEditor.vue';

export default {
  name: 'EditHome',
  components: {
    WorkflowEditor
  },
  setup() {
    const showWorkflowEditor = ref(false);
    
    return {
      showWorkflowEditor
    };
  }
};
</script>

<style scoped>
.edit-home {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f5f5f5;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.header h1 {
  margin: 0;
  font-size: 24px;
  color: #333;
}

.actions {
  display: flex;
  gap: 12px;
}

.action-button {
  padding: 10px 20px;
  background-color: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.action-button:hover {
  background-color: #1565c0;
}

.content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.welcome {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 24px;
}

.welcome-card {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 32px;
  max-width: 800px;
  width: 100%;
  text-align: center;
}

.welcome-card h2 {
  margin-top: 0;
  color: #333;
  font-size: 28px;
}

.welcome-card p {
  color: #666;
  line-height: 1.6;
  font-size: 16px;
}

.features {
  display: flex;
  justify-content: space-around;
  margin-top: 40px;
  flex-wrap: wrap;
  gap: 20px;
}

.feature {
  flex: 1;
  min-width: 200px;
  padding: 20px;
  border-radius: 8px;
  background-color: #f9f9f9;
  transition: transform 0.3s, box-shadow 0.3s;
}

.feature:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.feature-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
}

.feature-desc {
  color: #666;
  font-size: 14px;
}

.editor-wrapper {
  position: relative;
  height: 100%;
}

.back-button {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 100;
  padding: 8px 16px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.3s;
}

.back-button:hover {
  background-color: #e0e0e0;
}
</style>